#ifndef COMMON_H
#define COMMON_H

#include <stdbool.h>
#include <time.h>

// 用户信息结构
typedef struct {
    int id;
    char username[32];
    char password[32];
    int elo_rating;
    bool is_online;
} User;

// 游戏房间结构
typedef struct {
    int room_id;
    int player1_id;
    int player2_id;
    char player1_side; // 'W' or 'B'
    char board[8][8];
    bool is_player1_turn;
    bool game_over;
    char winner; // 'W', 'B', or 'D'
} GameRoom;

// 消息类型
typedef enum {
    MSG_LOGIN,
    MSG_REGISTER,
    MSG_LOGOUT,
    MSG_GET_ONLINE_USERS,
    MSG_REQUEST_GAME,
    MSG_RESPOND_GAME,
    MSG_MOVE,
    MSG_PROMOTION,   // 兵升变消息
    MSG_GAME_START,
    MSG_GAME_OVER,   // 游戏结束消息
    MSG_RESIGN,      // 认输消息
    MSG_CANCEL_GAME, // 取消游戏请求
    MSG_CHAT,
    MSG_ERROR
} MessageType;

#endif
